Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

322
Visualizações
"Uncaught SyntaxError: import declarations may only appear at top level of a module" while importing Swiper

I'm using swiper to create slider but the buttons ain't working. I tried to change the web browser but nothing changed.

The file extension is .php and I'm using xammp

this is my code:

js:

var swiper = new Swiper('.home-slider', {
    loop: true,
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },  
  });

html:

<secton class="home">

    <div class="swiper home-slider">
        <div class="swiper-wrapper">

            <div class="swiper-slide slide" style="background:url(1.png) no-repeat">
                <div class="content">
                    <a href="package.php" class="btn">Réserver</a>
                </div>
            </div>

            <div class="swiper-slide slide" style="background:url(3.png) no-repeat">
                <div class="content">
                    <a href="package.php" class="btn">Réserver</a>
                </div>
            </div>

            <div class="swiper-slide slide" style="background:url(3.png) no-repeat">
                <div class="content">
                    <a href="package.php" class="btn">Réserver</a>
                </div>
            </div>

        </div>
        <div class="swiper-button-next"></div>
        <div class="swiper-button-prev"></div>
    </div>

</section>

I tried:

import Swiper, { Navigation } from 'swiper';

Swiper.use([Navigation]);

and:

import SwiperCore, { Navigation } from 'swiper';
SwiperCore.use([Navigation]);

I used dev-tools and the console show:

Uncaught ReferenceError: Swiper is not defined
    <anonymous> http://localhost/website/script.js

after I added :

import Swiper, { Navigation, Pagination } from 'swiper';
Swiper.use([Navigation, Pagination]);

it becomes:

Uncaught SyntaxError: import declarations may only appear at top level of a module
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda